let userService = require("../src/services/userService");
let express=require("express");
let router= express.Router();

router.post("/login",async (req,res)=>{
     //获得客户端的参数
     let userName =req.body.userName;
     let pwd =req.body.pwd;
     console.log(userName,pwd)
     let result = await userService.login(userName,pwd);
     console.log(result);
     //判断是否登录成功
     if(result!=null){
        res.json({"code":0,"msg":"登录成功","username":result.username});
     }else{
        res.json({"code":1,"msg":"登录失败,用户名或者密码不正确"});
     }
})


module.exports=router;